package com.atguigu.springcloud.alibaba.controller;

import com.atguigu.springcloud.alibaba.service.StorageService;
import com.atguigu.springcloud.alibaba.domain.CommonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author xiaolong
 * @version 1.0
 * @description: TODO
 * @date 2021/10/10 14:57
 */
@RestController
public class StorageController {

    @Resource
    private StorageService storageService;


    /**
     * @param productId 商品id
     * @param count     商品数量
     * @return
     * @description: 扣减库存
     */
    @RequestMapping("/storage/decrease")
    public CommonResult decrease(Long productId, Integer count) {
        storageService.decrease(productId, count);
        return new CommonResult(200, "扣减库存成功");
    }
}
